<?php

function smarty_function_messages($params, &$smarty) {
	$view = $smarty->getTemplateVars('this');
	$params = $params + array(
		'class' =>  'messages ui-widget-content ui-corner-all ui-state-highlight',
	);
	if (empty($params['values'])) {
		$params['values'] = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger')->getMessages();
	}
	if (empty($params['values'])) {
		return '';
	}
	$messages = array();
	foreach ((array)$params['values'] as $message) {
		if (!empty($message)) {
			$messages[] = $view->translate($message);
		}
	}
	return '<ul class="'.$params['class'].'"><li>'.
		'<span class="ui-icon ui-icon-info" style="float:left;"></span>'.
		implode('</li><li>', $messages).
		'</li></ul>';
}
